<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link href="../../libs/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../../libs/app.css"/>
    <link rel="stylesheet" href="../../css/mui.listpicker.css"/>
    <link rel="stylesheet" href="../../css/mui.poppicker.css"/>
    <link rel="stylesheet" href="../../css/main.css"/>
    <link rel="stylesheet" href="../../css/s-askfor.css"/>
</head>

<body>
<div class="head">
    <img class="mui-action-back" src="../../images/all-left.png" alt="">
    <p>申请信息</p>
</div>
<div class="context2">
    <div class="state">
        <div><span class="two" style="background: white;color: black;">1</span>
            <p>申请人信息</p>
        </div>
        <div><span class="three">2</span>
            <p>申请结果</p>
        </div>
        <img class="gang1" src="../../images/white-gang.png" alt="">

    </div>
    <div class="message">
        <div>
            <p>姓名</p>
            <input type="text" placeholder="请输入姓名" id="name">
        </div>
        <div>
            <p>身份证号</p>
            <input type="text" placeholder="请输入身份证号码" id="id_card">
        </div>
        <div>
            <p>贷款金额</p><span class="s-monney">万元</span>
            <input type="text" placeholder="请输入申请金额" id="price">
        </div>
        <div>
            <p>是否缴纳社保</p>
            <select id="havaSocial_security">
                <option value="是">是</option>
                <option value="否">否</option>
            </select>
        </div>
        <div>
            <p>教育程度</p>
            <select id="education_level">
                <option value="小学">小学</option>
                <option value="初中">初中</option>
                <option value="高中">高中</option>
                <option value="大专">大专</option>
                <option value="本科">本科</option>
                <option value="研究生及以上">研究生及以上</option>
            </select>
        </div>
        <div>
            <p>职业信息</p>
            <select id="wordinfo">
                <option value="">请选择</option>
                <option value="学生">学生</option>
                <option value="医生">医生</option>
                <option value="公务员">公务员</option>
                <option value="技术研发">技术研发</option>
            </select>
        </div>
        <div>
            <p>是否有本地公积金</p>
            <select id="havaProvident_fund">
                <option value="是">是</option>
                <option value="否">否</option>
            </select>
        </div>
        <div>
            <p>名下是否有房产</p>
            <select id="haveHouse">
                <option value="是">是</option>
                <option value="否">否</option>
            </select>
        </div>
        <div>
            <p>名下是否有车产</p>
            <select id="haveCar">
                <option value="是">是</option>
                <option value="否">否</option>
            </select>
        </div>
        <div>
            <p>信用状况</p>
            <select id="credit">
                <option value="">请选择</option>
                <option value="一年内逾期超过3次或超过90天" title="一年内逾期超过3次或超过90天">一年内逾期超过3次或超过90天</option>
                <option value="一年内逾期少于3次或少于90天" title="一年内逾期少于3次或少于90天">一年内逾期少于3次或少于90天</option>
                <option value="无信用卡或无贷款" title="无信用卡或无贷款">无信用卡或无贷款</option>
                <option value="信用良好，无逾期" title="信用良好，无逾期">信用良好，无逾期</option>
            </select>
            <!--<input type="text" placeholder="请输入信用情况" id="credit">-->
        </div>
        <div id="showCityPicker3">
            <p>申请地点</p>
            <i class="icon-editCity"></i>
            <input readonly="true" id='cityResult3' class="ui-alert area" placeholder="请选择" type="text"/>
            <!--<input type="text" placeholder="请输入申请地" id="area">-->
        </div>
    </div>
    <div class="button">
        <button id="s-askfor2">下一步</button>
    </div>
</div>

<script src="../../libs/mui.min.js"></script>
<script src="../../js/jquery-3.1.1.min.js"></script>
<script src="../../js/url.js"></script>
<script src="../../js/city-data-3.js"></script>
<script src="../../js/mui.listpicker.js"></script>
<script src="../../js/mui.poppicker.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=AIEts6CoFGpdivbIz3uI3SrAG9iDB0Ko"></script>
<script src="../../js/location.js"></script>
<script src="../../js/city-public.js"></script>
<script>
    mui.init();

    $('#s-askfor2').on('tap', function () {
        var name = $('#name').val();
        var card = $('#id_card').val();
        var price = $('#price').val();
        var havaSocial_security = $('#havaSocial_security').val();
        var education_level = $('#education_level').val();
        var work = $('#wordinfo').val();
        var havaProvident_fund = $('#havaProvident_fund').val();
        var haveHouse = $('#haveHouse').val();
        var haveCar = $('#haveCar').val();
        var credit = $('#credit').val();
        var area = $('#cityResult3').val();

        var hanzi = /^[\u4e00-\u9fa5]{0,}$/;
        var sfzh = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
        var shouru = /^[0-9]+(.[0-9]{3})?$/;

        if ((!hanzi.test(name)) || name == '') {
            mui.toast('请检查您的姓名');
            return;
        } else if ((!sfzh.test(card)) || card == '') {
            mui.toast('请检查您的身份证号');
            return;
        } else if ((!shouru.test(price)) || price == '') {
            mui.toast('请检查您的借款金额');
            return;
        } else if (work == '' || credit == '' || area == '') {
            mui.toast('请检查您填写的信息');
            return;
        } else {

            if (localStorage.dk_type == 2) {
                b();
            } else {
                a();
            }
        }

        function a() {
            $.ajax({
                url: ur + 'rest/loanController/request',
                type: "post",
                dataType: "json",
                headers: {
                    "X-Token": localStorage.token
                },
                data: {
                    loanCode: 'xed',
                    associateId: localStorage.xed_id,
                    evaluateId: localStorage.evaluateId,
                    point: (localStorage.locationPoint ? localStorage.locationPoint : ''), // 坐标
                    params: '{"name":" ' + name + ' ","id_card":" ' + card + ' ","work":" ' + work + ' ","havaSocial_security":" ' + havaSocial_security + ' ","price":" ' + price + ' ","education_level":" ' + education_level +
                    ' ","credit":" ' + credit + ' ","havaProvident_fund":" ' + havaProvident_fund + ' ","haveHouse":" ' + haveHouse + ' ","haveCar":" ' + haveCar + ' ","area":" ' + area + ' ","freeService":"中介服务 "}'
                },
                success: function (data) {
                    if (data.meta.code == 'S002') {
                        mui.toast('贷款申请成功');
                        href('s-askfor2.html', 's-askfor2.html');
                    }
                }

            })
        }

        //快速贷款
        function b() {
            $.ajax({
                url: ur + 'rest/quickLoanController/quick-request',
                type: "post",
                dataType: "json",
                headers: {
                    "X-Token": localStorage.token
                },
                data: {
                    loanCode: 'xed',
                    partnerId: localStorage.fast_partner,
                    quickId: localStorage.fast_id,
                    evaluateId: localStorage.evaluateId,
                    params: '{"name":" ' + name + ' ","id_card":" ' + card + ' ","work":" ' + work + ' ","havaSocial_security":" ' + havaSocial_security + ' ","price":" ' + price + ' ","education_level":" ' + education_level +
                    ' ","credit":" ' + credit + ' ","havaProvident_fund":" ' + havaProvident_fund + ' ","haveHouse":" ' + haveHouse + ' ","haveCar":" ' + haveCar + ' ","area":" ' + area + ' ","freeService":"中介服务 "}'
                },
                success: function (data) {
                    if (data.meta.code == 'S002') {
                        mui.toast('贷款申请成功');
                        href('s-askfor2.html', 's-askfor2.html');
                    } else {
                        mui.toast(data.meta.message);
                    }
                }
            })
        }
    })
</script>
</body>

</html>